﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SlamDunk.MES.Domain.Entities.DefinitionContext;

namespace SlamDunk.MES.Repository.EntityConfigurations.DefinitionContext
{
    /// <summary>
    /// 物料清单项实体映射配置
    /// </summary>
    public class BomItemConfig : IEntityTypeConfiguration<BomItem>
    {
        /// <summary>
        /// 配置
        /// </summary>
        public void Configure(EntityTypeBuilder<BomItem> builder)
        {
            //配置属性
            builder.HasKey(bomItem => bomItem.Id).IsClustered(false);
            builder.Property(bomItem => bomItem.Quantity).HasPrecision(29, 10);
            builder.Property(bomItem => bomItem.LossCoefficient).HasPrecision(29, 10);

            //配置索引
            builder.HasIndex(bomItem => bomItem.AddedTime).IsUnique(false).IsClustered();
        }
    }
}
